package cn.xuanxuanyuhua.crm.web.controller;


import cn.xuanxuanyuhua.crm.query.QueryObject;
import cn.xuanxuanyuhua.crm.service.IPermissionService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/permission")
public class PermissionController {

    @Autowired
    private IPermissionService service;
    @RequiresPermissions(value = {"权限列表","permission:list"},logical = Logical.OR)
    @RequestMapping("/list")
    public String list(Model m, QueryObject qo) {
        m.addAttribute("pageInfo", service.query(qo));
        return "/permission/list";
    }

    @RequestMapping("/delete")
    public String delete(Long id) {
        service.delete(id);
        return "redirect:/permission/list.do";
    }

    @RequestMapping("/reload")
    public String reload() {
        service.reload();
        return "redirect:/permission/list.do";
    }

}
